using System;
using System.Collections.Generic;

namespace Adoor.Expression.AST
{
	/// <summary>
	/// Summary description for GroupByExpression.
	/// </summary>
	public class GroupByExpression
	{
		public ExpressionNode Expr;
		public GroupByExpression(ExpressionNode expr)
		{
			this.Expr = expr;
		}

		public static GroupByExpression ParseGroupByExpression(Scanner scanner)
		{
			ExpressionParser ep = new ExpressionParser();
			ExpressionNode expr = ep.ParseRowValueConstructor(scanner);
			return new GroupByExpression(expr);
		}

		public static GroupByExpression[] ParseGroupBy(Scanner scanner)
		{
			List<GroupByExpression> list = new List<GroupByExpression>();
			do
			{
				scanner.Scan();
				list.Add(GroupByExpression.ParseGroupByExpression(scanner));
			} while(scanner.Token == ScannerToken.Comma);
            return list.ToArray();
		}
	}
}
